﻿using System;
using CefSharp.WinForms;
using CefSharp;

namespace warehouse
{
   public class Browser
    {
        public Browser()
        {
            
        }
        public void Start(String url)
        {
            InitBrowser(url);
        }
        public ChromiumWebBrowser browser;
        public void InitBrowser(String url)
        {
            var settings = new CefSettings
            {
                Locale = "zh-CN",
                AcceptLanguageList = "zh-CN",
                MultiThreadedMessageLoop = true,
                RemoteDebuggingPort = 33229
            };
            settings.CefCommandLineArgs.Add("--disable-web-security", "1");//关闭同源策略,允许跨域
            settings.CefCommandLineArgs.Add("ppapi-flash-version", "18.0.0.209");//PepperFlash\manifest.json中的version
            settings.CefCommandLineArgs.Add("ppapi-flash-path", "PepperFlash\\pepflashplayer.dll");
            settings.CefCommandLineArgs.Add("--enable-system-flash", "1");//使用系统flash
            Cef.Initialize(settings);
            browser = new ChromiumWebBrowser(url);
            browser.Dock = System.Windows.Forms.DockStyle.Fill;
            browser.KeyboardHandler= new CEFKeyBoardHander();
        }
        public ChromiumWebBrowser getBrowser()
        {
           
            return browser;
        }
    }
}
